package com.tensquare.gathering.service;

import com.tensquare.gathering.dao.GatheringDao;
import com.tensquare.gathering.pojo.Gathering;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author zzb
 * @create 2021/2/21
 */
@Service
public class GatheringService {
    @Autowired
    private GatheringDao gatheringDao;
    //根据id查询
    @Cacheable(key = "#id",value = "gatheriing")
    public Gathering findById(String id){
        return gatheringDao.findById(id).get();
    }

    //添加gathering
    @CacheEvict(key = "#gathering.id")
    public void add(Gathering gathering){
        gatheringDao.save(gathering);
    }

    //修改gathering
    @CacheEvict(key = "#gathering.id")
    public void update(Gathering gathering){
        gatheringDao.save(gathering);
    }
}
